MPT.addTmpl('firstPayContent', function(result) {

	var html = [];
	var data = cfg['firstPay'];

	html.push('<h2>' + data.title + '</h2>');
	html.push('<div class="package">' );
	html.push('	<ul>');
	for (var i = 0; i < data.packages.length; i++) {
		if (result.bizObj.firstPayGet === 1) {
			html.push('		<li>');
			html.push('			<span class="package-dis"><img class="tooltip" rel="' + data.packages[i].tips + '" src="' + data.packages[i].disIcon + '" /></span><em>' + data.packages[i].name + '</em>');
			html.push('		</li>');
		} else {
			html.push('		<li>');
			html.push('			<span class="package-img"><img class="tooltip" rel="' + data.packages[i].tips + '" src="' + data.packages[i].icon + '" /></span><em>' + data.packages[i].name + '</em>');
			html.push('		</li>');
		}
	}
	html.push('	</ul>');
	html.push('</div>');
	//result.bizObj.firstPayMoney < 1
	if (result.bizObj.firstPayGet === 1) {
		html.push('<button disabled class="receive-btn done-btn button"></button>');
	} else {
		html.push('<button class="receive-btn button"></button>');
	}

	//html.push('		<a href="pay.htm?accountId=' + accountId + '&accountName=' + accountName + '&actorName=' + actorName + '&actorId=' + actorId + '&pServer=' + pServer + '&clientSrc=' + clientSrc + '" class="pay-btn button"></a>');
	html.push('		<a href="pay.htm" class="pay-btn button"></a>');



	return html.join('');

});

MPT.addTmpl('dayPayContent', function(result) {

	var html = [];
	//配置数据
	var data = cfg['dayPay'];
	//后台结果
	var result = result.bizObj;
	//是否已领取
	var isAlready = false;

	html.push('<ul class="th">');
	html.push('	<li class="th-one">');
	html.push('		<img src="' + _res_http_ + '/innerpay/images/activity-condtion.png" border="0" alt="">');
	html.push('	</li>');
	html.push('	<li class="th-two">');
	html.push('		<img src="' + _res_http_ + '/innerpay/images/activity-reward.png" border="0" alt="">');
	html.push('	</li>');
	html.push('	<li class="th-thr">');
	//html.push('		<a href="pay.htm?accountId=' + accountId + '&accountName=' + accountName + '&actorName=' + actorName + '&actorId=' + actorId + '&pServer=' + pServer + '&clientSrc=' + clientSrc + '" class="pay-btn button"></a>');
	html.push('		<a href="pay.htm" class="pay-btn button"></a>');
	html.push('	</li>');
	html.push('</ul>');
	html.push('<table cellpadding="0" cellpadding="0" width="622">');

	//循环生成礼品标题，礼品ICON，礼品TIPS
	for (var i = 0; i < data.length; i++) {
		html.push('	<tr>');
		html.push('		<td class="td-one">' + data[i].title + '</td>');
		html.push('		<td class="td-two">');
		for (var j = 0; j < data[i]['icon'].length; j++) {
			html.push('		<a class="tooltip" href="javascript:;" rel="' + data[i]['icon'][j]['tips'] + '">');
			html.push('			<img src="' + data[i]['icon'][j]['src'] + '"/><span class="icon-num">' + (data[i]['icon'][j]['num'] ? data[i]['icon'][j]['num'] : '') + '</span>')
			html.push('		</a>');
		}
		html.push('		</td>');
		html.push('		<td class="td-thr">');

		//循环匹配当前礼品是否已被领取

		for (var m = 0; m < (result['hdPayDayList'] && result['hdPayDayList'].length); m++) {

			if (result['hdPayDayList'][m] === i + 1) {
				isAlready = true;
				break;
			} else {
				isAlready = false;
			}
		}

		//判断是否已经领取，判断当前充值金额是否达到条件
		if (isAlready) {
			html.push('			<button disabled class="button day-pay-btn disabled received-done">已领取</button>');
		} else if (result['dayPayMoney'] >= data[i]['money']) {

			html.push('			<button class="button day-pay-btn light">可以领取</button>');
		} else {
			html.push('			<button disabled class="disabled day-pay-btn button">不可领取</button>');
		}

		html.push('		</td>');
		html.push('	</tr>');
	}
	html.push('</table>');

	return html.join('');

});

MPT.addTmpl('totalPayContent', function(result) {

	var html = [];
	//配置数据
	var data = cfg['totalPay'];
	//后台结果
	var result = result.bizObj;
	//是否已领取
	var isAlready = false;

	html.push('<ul class="th">');
	html.push('	<li class="th-one">');
	html.push('		<img src="' + _res_http_ + '/innerpay/images/activity-condtion.png" border="0" alt="">');
	html.push('	</li>');
	html.push('	<li class="th-two">');
	html.push('		<img src="' + _res_http_ + '/innerpay/images/activity-reward.png" border="0" alt="">');
	html.push('	</li>');
	html.push('	<li class="th-thr">');
	//html.push('		<a href="pay.htm?accountId=' + accountId + '&accountName=' + accountName + '&actorName=' + actorName + '&actorId=' + actorId + '&pServer=' + pServer + '" class="pay-btn button"></a>');
	html.push('		<a href="pay.htm" class="pay-btn button"></a>');
	html.push('	</li>');
	html.push('</ul>');
	html.push('<table cellpadding="0" cellpadding="0" width="622">');
	//循环生成礼品标题，礼品ICON，礼品TIPS
	for (var i = 0; i < data.length; i++) {
		html.push('	<tr>');
		html.push('		<td class="td-one">' + data[i].title + '</td>');
		html.push('		<td class="td-two">');
		for (var j = 0; j < data[i]['icon'].length; j++) {
			html.push('		<a class="tooltip" href="javascript:;" rel="' + data[i]['icon'][j]['tips'] + '">');
			html.push('			<img src="' + data[i]['icon'][j]['src'] + '"/><span class="icon-num">' + (data[i]['icon'][j]['num'] ? data[i]['icon'][j]['num'] : '') + '</span>')
			html.push('		</a>');
		}
		html.push('		</td>');
		html.push('		<td class="td-thr">');

		//循环匹配当前礼品是否已被领取
		for (var m = 0; m < (result['hdPayTotalList'] && result['hdPayTotalList'].length); m++) {
			if (result['hdPayTotalList'][m] === i + 1) {
				isAlready = true;
				break;
			} else {
				isAlready = false;
			}
		}

		//判断是否已经领取，判断当前充值金额是否达到条件
		if (isAlready) {
			html.push('			<button disabled class="button total-pay-btn disabled received-done">已领取</button>');
		} else if (result['totalPayMoney'] >= data[i]['money']) {
			html.push('			<button class="button total-pay-btn light">立即领取</button>');
		} else {
			html.push('			<button disabled class="disabled total-pay-btn button">不可领取</button>');
		}

		html.push('		</td>');
		html.push('	</tr>');
	}
	html.push('</table>');

	return html.join('');

});



MPT.addTmpl('ceContent', function(data) {

	var c = 0;
	var a = [];
	var isAlready = true;
	var effectHash = [
		[7, 8],
		[5, 6],
		[3, 4],
		[1, 2]
	];
	var cardInfo = data.bizObj.cardInfo;
	var useList = data.bizObj.useList;
	var effect = [{
		num: 250000,
		name: '25万战力'
	}, {
		num: 180000,
		name: '18万战力'
	}, {
		num: 120000,
		name: '12万战力'
	}, {
		num: 80000,
		name: '8万战力'
	}];

	var _data = [
		[{
			idx: 1,
			isAlready: false,
			twoOrone: false,
			num: 0,
			exp: 80000
		}, {
			idx: 2,
			isAlready: false,
			twoOrone: false,
			num: 'infinite',
			exp: 80000,
			tips: '/innerpay/images/ce/ce-zlzzlb-chu.jpg'
		}],
		[{
			idx: 3,
			isAlready: false,
			twoOrone: false,
			num: 0,
			exp: 120000
		}, {
			idx: 4,
			isAlready: false,
			twoOrone: false,
			num: 'infinite',
			exp: 120000,
			tips: '/innerpay/images/ce/ce-zlzzlb-z.jpg'
		}],
		[{
			idx: 5,
			isAlready: false,
			twoOrone: false,
			num: 0,
			exp: 180000
		}, {
			idx: 6,
			isAlready: false,
			twoOrone: false,
			num: 'infinite',
			exp: 180000,
			tips: '/innerpay/images/ce/ce-zlzzlb-g.jpg'
		}],
		[{
			idx: 7,
			isAlready: false,
			twoOrone: false,
			num: 0,
			exp: 250000,
			tips: '/innerpay/images/ce/qiongqiong.jpg'
		}, {
			idx: 8,
			isAlready: false,
			twoOrone: false,
			num: 'infinite',
			exp: 250000,
			tips: '/innerpay/images/ce/ce-zlzzlb-c.jpg'
		}]
	];


	for (var i = 0; i < useList.length; i++) {
		for (var j = 0; j < _data.length; j++) {
			for (var m = 0; m < _data[j].length; m++) {
				if (useList[i] === _data[j][m].idx) {
					_data[j][m].isAlready = true;
					_data[j][0].twoOrone = true;
					_data[j][1].twoOrone = true;
				}
			}
		}
	}

	for (var i = 0; i < cardInfo.length; i++) {
		for (var x in cardInfo[i]) {
			for (var j = 0; j < _data.length; j++) {
				for (var m = 0; m < _data[j].length; m++) {
					if (x == _data[j][m].idx) {
						_data[j][m].num = cardInfo[i][x];
					}
				}
			}
		}
	}

	a.push('<ul class="card-box">');

	for (var i = _data.length - 1; i >= 0; i--) {
		for (var j = 0; j < _data[i].length; j++) {

			if (_data[i][j].tips) {
				a.push('<li data-type="' + (i + 1) + '" data-idx="' + _data[i][j].idx + '" class="cards tooltip cards-' + c + '" rel="' + (_res_http_ + _data[i][j].tips) + '">');
			} else {
				a.push('<li data-type="' + (i + 1) + '" data-idx="' + _data[i][j].idx + '" class="cards cards-' + c + '" >');

			}
			if (_data[i][j].num === 'infinite') {
				a.push('<span class="num"><i>无限</i></span>');
			} else {
				a.push('<span class="num"><i>余' + _data[i][j].num + '</i></span>');
			}

			if (_data[i][j].isAlready) {
				a.push('		<div class="disa"></div>');
				a.push('		<span class="already"></span>');
			} else if (_data[i][j].twoOrone) {
				a.push('		<div class="twoOrOne"></div>');
			} else if (_data[i][j].exp > _ce * 1) {
				a.push('		<div class="disa"></div>');
			} else if(_data[i][j].num <= 0){
				a.push('		<div class="ce-zero"></div>');
			}

			a.push('</li>')
			c++;
		}
	}

	a.push('</ul>');


	a.push('<div class="label-box">');


	for (var i = 0; i < effect.length; i++) {
		isAlready = true;
		a.push('	<div class="label">');
		a.push('		<strong>' + effect[i].name + '</strong>');

		if (useList.length) {
			for (var j = 0; j < effectHash.length; j++) {
				for (var k = 0; k < effectHash[j].length; k++) {
					for (var l = 0; l < useList.length; l++) {
						if (effectHash[j][k] === useList[l]) {
							if (j === i) {
								a.push('	<em class="success">已领取</em>');
								isAlready = false;
							}
						}
					}
				}
			}
		}

		if (isAlready) {
			if (_ce * 1 >= effect[i].num) {
				a.push('	<em class="success">已达标</em>');
			} else {
				a.push('	<em class="fail">未达标</em>');
			}
		}

		a.push('	</div>');
	}
	a.push('</div>');


	return a.join('');

});